package org.boulderfoodrescue.webapp.server.pickupreport;

import java.util.List;
import java.util.logging.Logger;

import org.boulderfoodrescue.webapp.client.rpc.PickupReportService;
import org.boulderfoodrescue.webapp.client.rpc.PickupService;
import org.boulderfoodrescue.webapp.server.pickups.PickupDatabase;
import org.boulderfoodrescue.webapp.server.pickups.PickupServiceImpl;
import org.boulderfoodrescue.webapp.server.users.UserAccountsDatabase;
import org.boulderfoodrescue.webapp.shared.Pickup;
import org.boulderfoodrescue.webapp.shared.PickupReport;
import org.boulderfoodrescue.webapp.shared.UserAccount;
import org.boulderfoodrescue.webapp.shared.UserAccountDetails.AccessLevel;

import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;

public class PickupReportServiceImpl extends RemoteServiceServlet implements PickupReportService {

	@Override
	public Long savePickupReport(PickupReport report) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<PickupReport> getAllPcikupReports() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<PickupReport> getPickupReports(Long pickupDatabaseKey) {
		// TODO Auto-generated method stub
		return null;
	}
//	private static final Logger log = Logger.getLogger(PickupServiceImpl.class.getName());
//	
//	@Override
//	public Long savePickup(Pickup pickup) {
//		UserService userService = UserServiceFactory.getUserService();
//		User person = userService.getCurrentUser();
//		if(person == null){
//			log.warning("User is not logged in. Cannot execute savePickup() call");
//			return null;
//		}
//		UserAccount user = UserAccountsDatabase.getUser(person.getEmail());
//		if(user.getAccessLevel().compareTo(AccessLevel.Volunteer) < 0)
//		{
//			log.warning("User does not have the proper privleges to perform this operation: "+person.getEmail() + " access level = " + user.getAccessLevel());
//			return null;
//		}
//		if(pickup.getDatabaseKey() != null && pickup.getDatabaseKey() != 0){
//			return PickupDatabase.updatePickup(pickup); 
//		}
//		return PickupDatabase.addPickup(pickup);
//	}
//
//	@Override
//	public List<Pickup> getPickups() {
//		UserService userService = UserServiceFactory.getUserService();
//		User person = userService.getCurrentUser();
//		if(person == null){
//			log.warning("User is not logged in. Cannot execute getPickups() call");
//			return null;
//		}
//		UserAccount user = UserAccountsDatabase.getUser(person.getEmail());
//		if(user.getAccessLevel().compareTo(AccessLevel.Volunteer) < 0)
//		{
//			log.warning("User does not have the proper privleges to perform this operation: "+person.getEmail() + " access level = " + user.getAccessLevel());
//			return null;
//		}
//		return PickupDatabase.getPickups(1000);
//	}
//
//	@Override
//	public Boolean removePickup(Pickup pickup) {
//		// TODO Auto-generated method stub
//		return null;
//	}
//
//	@Override
//	public Long savePickupReport(PickupReport report) {
//		UserService userService = UserServiceFactory.getUserService();
//		User person = userService.getCurrentUser();
//		if(person == null){
//			log.warning("User is not logged in. Cannot execute savePickupReport() call");
//			return null;
//		}
//		UserAccount user = UserAccountsDatabase.getUser(person.getEmail());
//		if(user.getAccessLevel().compareTo(AccessLevel.Volunteer) < 0)
//		{
//			log.warning("User does not have the proper privleges to perform this operation: "+person.getEmail() + " access level = " + user.getAccessLevel());
//			return null;
//		}
//		if(report.getDatabaseKey() != null && report.getDatabaseKey() != 0){
//			return PickupReportDatabase.updatePickupReport(report); 
//		}
//		return PickupReportDatabase.addPickupRecport(report);
//	}
//
//	@Override
//	public List<PickupReport> getAllPcikupReports() {
//		UserService userService = UserServiceFactory.getUserService();
//		User person = userService.getCurrentUser();
//		if(person == null){
//			log.warning("User is not logged in. Cannot execute getPickups() call");
//			return null;
//		}
//		UserAccount user = UserAccountsDatabase.getUser(person.getEmail());
//		if(user.getAccessLevel().compareTo(AccessLevel.Volunteer) < 0)
//		{
//			log.warning("User does not have the proper privleges to perform this operation: "+person.getEmail() + " access level = " + user.getAccessLevel());
//			return null;
//		}
//		return PickupReportDatabase.getPickupReports(1000);
//	}
//
//	@Override
//	public List<PickupReport> getPickupReports(Long pickupDatabaseKey) {
//		// TODO Auto-generated method stub
//		return null;
//	}

}